﻿package core.ui.dialogs
{
    import core.enum.*;
    import core.image.*;
    import core.ui.controls.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.utils.*;

    public class BitmapOperationDialogBase extends Dialog
    {
        var offset:Point;
        var bm:BitmapData;
        var bc:BitmapData;
        var locked:Boolean;
        var selection:Selection;

        public function BitmapOperationDialogBase(param1:Tuyitu, param2:String, param3:int, param4:int, param5:Action)
        {
            super(param1, param2, param3, param4, false);
            param1.canvas.history.Prepare(param5);
            this.selection = param1.canvas.selection;
            if (param1.canvas.layer.hasBitmap)
            {
                this.offset = param1.canvas.layer.offset;
                this.bm = param1.canvas.layer.bitmap.bitmapData;
                this.bc = this.bm.clone();
                setTimeout(this.Change, 150);
            }
            else
            {
                this.locked = true;
            }
            return;
        }// end function

        override public function OKClick(event:MouseEvent) : void
        {
            ed.canvas.history.Commit();
            ed.canvas.UpdateAfterEdit();
            Close();
            return;
        }// end function

        override public function CloseClick(event:MouseEvent) : void
        {
            if (this.bm != null)
            {
                this.bm.copyPixels(this.bc, this.bm.rect, this.bm.rect.topLeft);
                this.bc.dispose();
                this.bc = null;
            }
            Close();
            return;
        }// end function

        public function Change(... args) : void
        {
            return;
        }// end function

    }
}
